<template>
    <swiper :options="swiperOption">
        <swiper-slide v-for="(page, index) of pages" :key="index">
            <div class="icons" >
                <div class="icon" v-for="(item,index) of page" :key="item.id">
                    <div class="icon-img">
                        <img :src="item.imgUrl" alt="" class="icon-img-content">
                    </div>
                    <p class="icon-desc">{{item.desc}}</p>
                </div>
            </div>
        </swiper-slide>
    </swiper>
</template>

<script>
  export default {
    name: 'homeNav',
    props:{
      list:Array
    },
    data (){
      return{
        swiperOption:{
          loop:false
        }
      }
    },
    computed:{
      pages () {
        const pages = [];
        this.list.forEach((item, index) => {
            const page = Math.floor(index / 8);
            if(!pages[page]){
              pages[page] = []
            }
            pages[page].push(item)
        })
        return pages
      }
    }
  }
</script>

<style type="text/stylus" lang="stylus" scoped>
    @import "~assets/style/param.styl"
    @import "~assets/style/methods.styl"
    .icons
        width 100%
        height 0
        padding-bottom 50%
        overflow hidden
    .icon
        position relative
        overflow hidden
        float left
        width 25%
        height 0
        padding-bottom 25%
    .icon-img
        position absolute
        top 0
        letter-spacing 0
        bottom .44rem
        box-sizing border-box
        padding .1rem
        width 100%
    .icon-img-content
        height 100%
        display block
        margin 0 auto
    .icon-desc
        position absolute
        bottom 0
        color $themeFontColor
        height .44rem
        line-height .44rem
        text-align center
        width 100%
        sandian()

</style>
